<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="{$smarty.const.ADMIN_CSS_PATH}style.css" rel="stylesheet" type="text/css" />
<!--<link href="{$smarty.const.CSS_PATH}bootstrap.min.css" rel="stylesheet" type="text/css" />-->
<link href="css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{$smarty.const.ADMIN_JS_PATH}jquery.js"></script>
<script type="text/javascript" src="{$smarty.const.ADMIN_JS_PATH}jquery.idTabs.min.js"></script>
<script type="text/javascript" src="{$smarty.const.ADMIN_JS_PATH}select-ui.min.js"></script>
<script type="text/javascript" src="editor/kindeditor.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$(".select3").uedSelect({
		width : 100
	});
});

</script>
<style type="text/css">
.scbtn{ background-image:none!important;}
.refunddialog{
	width: 485px;
    height: 260px;
    position: absolute;
    top: 10%;
    left: 30%;
    background: #fcfdfd;
    box-shadow: 1px 8px 10px 1px #9b9b9b;
    border-radius: 1px;
    behavior: url(js/pie.htc);
    display: none;
    z-index: 111111;
}
.acceptrefund, .refuserefund{
	    width: 96px;
    height: 35px;
    line-height: 35px;
    color: #fff;
    background: url({$smarty.const.ADMIN_IMAGES_PATH}/btnbg1.png) repeat-x;
    font-size: 14px;
    font-weight: bold;
    border-radius: 3px;
    cursor: pointer;
}
</style>
</head>

<body>

	
    
    <div class="formbody">
    
    
    <div id="usual1" class="usual"> 
    
  	<div id="tab2" class="tabson">
    
    
    <table class="imgtable">
    
    <thead>
    <tr>
    <th>订单编号</th>
    <th>用户</th>
    <th style="width: 300px;">商品</th>
    <th>金额</th>
    <th style="width: 400px;">地址</th>
    <th>状态</th>
    </tr>
    </thead>
    
    <tbody style="text-align: center;">
    {foreach $orders as $k=>$v}
    <tr>
    <td>{$v.uid}</td>
    <td>{$v.user_id}({$v.name})</td>
    <td>{foreach json_decode($v.goods,true) as $gk=>$gv}{$gv.good.name}X{$gv.quantity},{/foreach}</td>
    <td>{$v.paid_fee}</td>
    {$a=json_decode($v.address,true)}
    <td>{$a.name}{$a.phone}&nbsp;&nbsp;&nbsp;&nbsp;{$a.province}{$a.city}{$a.town}{$a.detail}</td>
    {if $v.status==1}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: cornflowerblue;" value="{$v.uid}" class="scbtn sendbt">发货</button></td>
    {else if $v.status==2}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: orange;" value="{$v.uid}" class="scbtn waitreceiver">待收货</button></td>
    {else if $v.status==3}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: gold;" value="{$v.uid}" class="scbtn">待评价</button></td>
    {else if $v.status==4}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: orangered;" value="{$v.uid}" class="scbtn waitrefund">申请退款</button></td>
    {else if $v.status==5}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: orangered;" value="{$v.uid}" class="scbtn waitrefund">已拒绝退款</button></td>
    {else if $v.status==6}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: lightgreen;" value="{$v.uid}" class="scbtn">已完成</button></td>
    {else if $v.status==7}
    <td><button style="height:35px;margin-bottom: 17px;margin-top: 17px;background-color: orangered;" value="{$v.uid}" class="scbtn">已同意退款</button></td>
    {/if}
    </tr>
    {/foreach}
    </tbody>
    </table>
    
    <div class="pagin">
    	<div class="message">共<i class="blue">{$total}</i>条记录，每页显示&nbsp;<i class="blue">10&nbsp;</i>条</div>
        <ul class="paginList">
        	{$pagelist}
        </ul>
    </div>
    
    <!--<div>
    	<iframe name="kuaidi100" src="https://www.kuaidi100.com/frame/index.html" width="960" height="880" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
	</div>-->
    <!--发货弹出框-->
    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a class="close"></a></div>
        <!--<form action="{$smarty.const.__CONTROLLER__}/sendgoods" method="post">-->
      <div class="tipinfo">
        <div class="tipright">
        <input type="text" class="dfinput" name="uid" id="uid" value="" placeholder="uid" style="display: none;"/>
        <input type="text" class="dfinput" name="delcom" id="delcom" placeholder="物流公司" style="width: 270px;margin-bottom: 30px;position:relative; left: 10%;"/>
        <input type="text" class="dfinput" name="delnum" id="delnum" placeholder="快递单号" style="width: 270px;position:relative; left: 10%;"/>
        </div>
        </div>
        
        <div class="tipbtn" style="position:relative; left: 5%;">
        <input name="" type="submit"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>
    	<!--</form>-->
    </div>
    <!--退款弹出框-->
    <div class="refunddialog" >
    	<div class="tiptop"><span>提示信息</span><a class="closerefund"></a></div>
        <!--<form action="{$smarty.const.__CONTROLLER__}/sendgoods" method="post">-->
      <div class="tipinfo">
        <div class="tipright">
        <input type="text" class="dfinput" name="" id="refunduid" value="" placeholder="uid" style="display: none;"/>
        <label style="font-size: 21px;">退款原因:<b id="reason" style="font-size: 21px;color: red;">dd</b></label>
        </div>
        </div>
        
        <div class="tipbtn" style="position:relative; left: 5%;">
        <input name="" type="submit"  class="acceptrefund" value="同意退款" />&nbsp;
        <input name="" type="button"  class="refuserefund" value="拒绝退款" />
        </div>
    	<!--</form>-->
    </div>
    
    </div>  
       
	</div> 
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	$(".sendbt").click(function(){
		$('#uid').val($(this).val());
		$('.tip').fadeIn();
		console.log($(this).val());
	})
	$(".close,.cancel").click(function(){
		$('.tip').fadeOut();
//		console.log($(this).val());
	})
	$(".closerefund").click(function(){
		$('.refunddialog').fadeOut();
//		console.log($(this).val());
	})
	$(".sure").click(function(){
		var data={
			uid:$("#uid").val(),
			delcom:$("#delcom").val(),
			delnum:$("#delnum").val(),
		}
		console.log(data);
		$.post("{$smarty.const.__CONTROLLER__}/sendgoods", data, function(ret){
				console.log(ret);
				if(ret.errorcode){
					$(".tip").fadeOut();
					alert(ret.error);
				}else{
					$(".tip").fadeOut();
					window.location.reload();
				}
			})
		
	})
	$('.waitrefund').click(function(){
		//获取退款原因
		var wf=$(this);
		$('#refunduid').val(wf.val());
		var data={
			uid:wf.val(),
		}
		$.post("{$smarty.const.__CONTROLLER__}/getrefundreason", data, function(ret){
				console.log(ret);
				if(ret){
					$("#reason").text(ret);
					$('.refunddialog').fadeIn();
				}else{
					alert("获取退款原因失败");
				}
			})
	})
	//同意或拒绝退款
	$(".acceptrefund,.refuserefund").click(function(){
		console.log($(this).val());
//		alert($('#refunduid').val());
		var data2={
			uid:$('#refunduid').val(),
			result:$(this).val()=="同意退款"?1:0,
		}
		console.log(data2);
		$.post("{$smarty.const.__CONTROLLER__}/torefund", data2, function(ret){
				console.log(ret);
				$('.refunddialog').fadeOut();
				if(ret.errorcode){
					alert(ret.error);
				}
				
			})
	})
	</script>
    </div>

</body>
</html>
